package nus.mtech.util;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

/**
 * @author Alvin Lee
 *
 */
public class ReadFile {
	/**
	 * This static method is to read in data file and return the data as String
	 * 
	 * @param String
	 *            - fileName
	 */
	public static String readFile(String fileName) {
		BufferedReader in = null;
		StringBuffer readBuffer = new StringBuffer();
		try {
			in = new BufferedReader(new FileReader(fileName));
			String str;
			while ((str = in.readLine()) != null) {
				readBuffer.append(str);
			}
			in.close();
			in = null;
		} catch (IOException e) {
			System.out.println("ReadFile L34:" + e.toString());
		} finally {
			try {
				if (in != null) {
					in.close();
				}
			} catch (IOException e) {
				System.out.println("ReadFile L41: " + e.toString());
			}
		}
		return readBuffer.toString();
	}
}
